### must use go >= 1.18

TARGET_DIR=dist
APP=dp

# Go parameters
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GODOWNLOAD=$(GOCMD) mod download

dev:
	go run main.go search --debug --city 上海 牛太叔

login:
	go run main.go login --debug

# 北京 呷浦呷浦
# 杭州 咬不得
# 北京 桃娘
# 上海 牛太叔
search:
	go run main.go search --debug --city 北京 桃娘

# for `url`  cmd use: go run main.go shop --debug --url https://www.dianping.com/shop/l4WRabvo5HnJMGsJ
# for `file` cmd use: go run main.go shop --debug --file tmp/北京_桃娘.txt
shop:
	go run main.go shop --debug --file tmp/北京_桃娘.txt


review: 
	go run main.go review --debug --shop k7M9KlVJp8xm9BOo

# for `search` upload: go run main.go upload search  -D -F crawled/search/北京_桃娘.json
# for `shop`   upload: go run main.go upload shop    -D -F crawled/shop/G2lcX14OmECrk6oF.json -F crawled/shop/G3Xk5U3SfOvr3jEn.json 
# for `review` upload: go run main.go upload review  -D -S k7M9KlVJp8xm9BOo -F crawled/review/k7M9KlVJp8xm9BOo.json 
upload:
	go run main.go upload search  -D -F crawled/search/北京_桃娘.json

download:
	$(GODOWNLOAD)

build:
	rm -rf $(TARGET_DIR)
	mkdir -p $(TARGET_DIR)
	#cp conf/config.toml $(TARGET_DIR)/config.toml
	$(GOBUILD) -o $(TARGET_DIR)/$(APP) cmd/main.go

clean:
	rm -rf $(TARGET_DIR)

run:
	nohup $(TARGET_DIR)/$(APP) -c=$(TARGET_DIR)/config.toml 2>&1 > $(TARGET_DIR)/$(APP).log &

stop:
	pkill -f $(TARGET_DIR)/$(APP)
